package NowCoderHuaWei;
import java.util.*;
public class Test02{
    public static void main(String[] args)
        {
        Scanner in=new Scanner(System.in);
        while(in.hasNext())
        {
            String str=in.nextLine();
            String sch=in.next();
            Character ch=sch.charAt(0);
            char[] cha=str.toCharArray();
            int num=0;
            for(char c:cha)
            {
            	if((int)c==(int)ch||Math.abs((int)c-(int)ch)==32)
            		num++;
            }
            System.out.println(num);
        }
        in.close();
    }
}
